home *** CD-ROM | disk | FTP | other *** search
/ The X-Philes (2nd Revision) / The X-Philes Number 1 (1995).iso / xphiles / hp95 / ylisp.mis < prev    next >
Internet Message Format  |  1992-05-20  |  5KB

  1. From micro-heart-of-gold.mit.edu!wupost!sdd.hp.com!hpscdc!hplextra!hpfcso!hpfcmdd!hpbbrd!peer Thu, 2 Apr 1992 12:40:22 GMT
  2. From: peer@hpbbrd.bbn.hp.com (Peter Ernst)
  3. Date: Thu, 2 Apr 1992 12:40:22 GMT
  4. Subject: Re: LISP for the HP95LX
  5. Message-ID: <78600004@hpbbrd.bbn.hp.com>
  6. Organization: HP Mechanical Design Division
  7. Path: micro-heart-of-gold.mit.edu!wupost!sdd.hp.com!hpscdc!hplextra!hpfcso!hpfcmdd!hpbbrd!peer
  8. Newsgroups: comp.sys.palmtops
  9. References: <78600001@hpbbrd.bbn.hp.com>
  10.  
  11. In the ylisp95.zip archive on 'ftp.irisa.fr' there is one important lisp file
  12. missing. You will wind it attached to this mail.
  13.  
  14. Sorry :-(
  15.        ----- cut here ---------
  16.  
  17. # This is a shell archive.  Remove anything before this line,
  18. # then unpack it by saving it in a file and typing "sh file".
  19. #
  20. # Wrapped by Peter Ernst <peer@hpbbrd> on Thu Apr  2 05:38:53 1992
  21. #
  22. # This archive contains:
  23. #    ylisp.lsp    
  24. #
  25.  
  26. LANG=""; export LANG
  27. PATH=/bin:/usr/bin:$PATH; export PATH
  28.  
  29. echo x - ylisp.lsp
  30. cat >ylisp.lsp <<'@EOF'
  31. (format *standard-output*  "YLISP-Version ~A~%" *version*)
  32.  
  33. ; SYMBOL FUNCTIONS
  34.  
  35. (defmacro defvar (sym &optional val)
  36.   `(if (boundp ',sym) ,sym (setq ,sym ,val)))
  37. (defmacro defparameter (sym val)
  38.   `(setq ,sym ,val))
  39. (defmacro defconstant (sym val)
  40.   `(setq ,sym ,val))
  41.  
  42. ; (makunbound sym) - make a symbol value be unbound
  43. (defmacro makunbound (sym)
  44.   `(progn (setf (symbol-value ,sym) '*unbound*) ,sym)
  45. )
  46.  
  47. ; (fmakunbound sym) - make a symbol function be unbound
  48. (defmacro fmakunbound (sym)
  49.   `(progn (setf (symbol-function ,sym) '*unbound*) ,sym)
  50. )
  51.  
  52. ; LIST FUNCTIONS
  53.  
  54. ; (mapcan fun list [ list ]...)
  55. (defmacro mapcan (&rest args) `(apply #'nconc (mapcar ,@args)))
  56.  
  57. ; (mapcon fun list [ list ]...)
  58. (defmacro mapcon (&rest args) `(apply #'nconc (maplist ,@args)))
  59.  
  60. ;; The following functionality is implemented as macros for the sake
  61. ;; of compatibility with setf
  62.  
  63. (defmacro caar (list)
  64.   `(cxr ,list "aa")
  65. )
  66. (defmacro cadr (list)
  67.   `(cxr ,list "ad")
  68. )
  69. (defmacro cdar (list)
  70.   `(cxr ,list "da")
  71. )
  72. (defmacro cddr (list)
  73.   `(cxr ,list "dd")
  74. )
  75. (defmacro caaar (list)
  76.   `(cxr ,list "aaa")
  77. )
  78. (defmacro caadr (list)
  79.   `(cxr ,list "aad")
  80. )
  81. (defmacro cadar (list)
  82.   `(cxr ,list "ada")
  83. )
  84. (defmacro caddr (list)
  85.   `(cxr ,list "add")
  86. )
  87. (defmacro cdaar (list)
  88.   `(cxr ,list "daa")
  89. )
  90. (defmacro cdadr (list)
  91.   `(cxr ,list "dad")
  92. )
  93. (defmacro cddar (list)
  94.   `(cxr ,list "dda")
  95. )
  96. (defmacro cdddr (list)
  97.   `(cxr ,list "ddd")
  98. )
  99. (defmacro caaaar (list)
  100.   `(cxr ,list "aaaa")
  101. )
  102. (defmacro caaadr (list)
  103.   `(cxr ,list "aad")
  104. )
  105. (defmacro caadar (list)
  106.   `(cxr ,list "aada")
  107. )
  108. (defmacro caaddr (list)
  109.   `(cxr ,list "aadd")
  110. )
  111. (defmacro cadaar (list)
  112.   `(cxr ,list "adaa")
  113. )
  114. (defmacro cadadr (list)
  115.   `(cxr ,list "adad")
  116. )
  117. (defmacro caddar (list)
  118.   `(cxr ,list "adda")
  119. )
  120. (defmacro cadddr (list)
  121.   `(cxr ,list "addd")
  122. )
  123. (defmacro cdaaar (list)
  124.   `(cxr ,list "daaa")
  125. )
  126. (defmacro cdaadr (list)
  127.   `(cxr ,list "daad")
  128. )
  129. (defmacro cdadar (list)
  130.   `(cxr ,list "dada")
  131. )
  132. (defmacro cdaddr (list)
  133.   `(cxr ,list "dadd")
  134. )
  135. (defmacro cddaar (list)
  136.   `(cxr ,list "ddaa")
  137. )
  138. (defmacro cddadr (list)
  139.   `(cxr ,list "ddad")
  140. )
  141. (defmacro cdddar (list)
  142.   `(cxr ,list "ddda")
  143. )
  144. (defmacro cddddr (list)
  145.   `(cxr ,list "dddd")
  146. )
  147.  
  148. (defmacro first (list)
  149.   `(car ,list)
  150. )
  151.  
  152. (defmacro second (list)
  153.   `(cxr ,list "ad")
  154. )
  155.  
  156. (defmacro third (list)
  157.   `(cxr ,list "add")
  158. )
  159.  
  160. (defmacro fourth (list)
  161.   `(cxr ,list "addd")
  162. )
  163.  
  164. (defmacro rest (list)
  165.   `(cdr ,list)
  166. )
  167.  
  168. ; MISC
  169.  
  170. ; (set-macro-character ch fun [ tflag ])
  171. (defun set-macro-character (ch fun &optional tflag)
  172.     (setf (aref *readtable* (char-int ch))
  173.           (cons (if tflag :tmacro :nmacro) fun))
  174.     t)
  175.  
  176. ; (get-macro-character ch)
  177. (defun get-macro-character (ch)
  178.   (if (consp (aref *readtable* (char-int ch)))
  179.     (cdr (aref *readtable* (char-int ch)))
  180.     nil))
  181.  
  182. ; SYSTEM FUNCTIONS
  183.  
  184. ; (save-def fun) - save a function definition to a file
  185. (defmacro save-def (name &aux
  186.                          (fname (strcat (symbol-name name) ".lsp"))
  187.                          (stream (open fname :direction :output)))
  188.  
  189.   (if stream `(progn (pp-def ,name ,stream)
  190.                      (close ,stream)
  191.                      ,fname)
  192.      (nil))
  193.   
  194. )
  195.  
  196. ; (debug) - enable debug breaks
  197. (defun debug (s)
  198.        (setq *breakenable* s))
  199.  
  200. ; initialize to enable breaks but no trace back
  201. (setq *breakenable* t)
  202. (setq *tracenable* nil)
  203.  
  204. ; INPUT/OUTPUT FUNCTIONS
  205.  
  206. (DEFUN PP-FILE (FILENAME &OPTIONAL STREAMOUT)
  207.   (OR STREAMOUT (SETQ STREAMOUT *STANDARD-OUTPUT*))
  208.   (PRINC "; Listing of " STREAMOUT)
  209.   (PRINC FILENAME STREAMOUT)
  210.   (TERPRI STREAMOUT)
  211.   (TERPRI STREAMOUT)
  212.   (DO* ( (FP (OPEN FILENAME))
  213.          (EXPR (READ FP) (READ FP)))
  214.        ((NULL EXPR) (CLOSE FP))
  215.        (PPRINT EXPR STREAMOUT)
  216.        (TERPRI STREAMOUT)))
  217.  
  218.  
  219. ; Print a lambda or macro form as a DEFUN or DEFMACRO:
  220.  
  221. (DEFMACRO PP-DEF (NAME &OPTIONAL STREAM
  222.                        &AUX (EXPR (get-lambda-expression
  223.                                    (symbol-function name))))
  224.   `(pprint
  225.     ',(nconc (list (if (eq (car expr) 'LAMBDA) 'DEFUN 'DEFMACRO)
  226.                   name)
  227.             (cdr expr))
  228.     ,@(if stream (list stream))))
  229.  
  230. (defconstant pi 3.14159265358979323846)
  231.  
  232. ;; now load the user's startup file
  233.  
  234. (load "startup")
  235. @EOF
  236.  
  237. chmod 440 ylisp.lsp
  238.  
  239. exit 0
  240.  
  241.